package com.xuxin.nantai.presenter;

import com.xuxin.nantai.bean.BaseBean;
import com.xuxin.nantai.bean.DefaultGroupBean;
import com.xuxin.nantai.bean.FlowLineBean;
import com.xuxin.nantai.bean.GroupBean;
import com.xuxin.nantai.bean.ProducerBean;
import com.xuxin.nantai.contract.CompleteDetailUpdateContract;
import com.xuxin.nantai.model.CompleteDetailUpdateModel;

/**
 * Created by xu_xin
 * Created on 2020.06.09 0009
 */
public class CompleteDetailUpdatePresenter implements CompleteDetailUpdateContract.Presenter {
    private CompleteDetailUpdateModel model;
    private CompleteDetailUpdateContract.View view;

    public CompleteDetailUpdatePresenter(CompleteDetailUpdateContract.View view) {
        model = new CompleteDetailUpdateModel();
        this.view = view;
    }

    @Override
    public void getGroups() {
        if (null != model) {
            model.getGroups(this);
        }
    }

    @Override
    public void getFlowLine() {
        if (null != model) {
            model.getFlowLine(this);
        }
    }

    @Override
    public void getProducer(String cDepCode,String LineName) {
        if (null != model) {
            model.getProducer(this, cDepCode,LineName);
        }
    }

    @Override
    public void update(String LoginName,
                       String UserName,
                       String Guid,
                       String DID,
                       String HID,
                       String GroupName,
                       String GroupCode,
                       String ProductName,
                       String ProductCode,
                       String DefectDes,
                       String DefectNum) {
        if (null != model) {
            model.update(this,
                    LoginName,
                    UserName,
                    Guid,
                    DID,
                    HID,
                    GroupName,
                    GroupCode,
                    ProductName,
                    ProductCode,
                    DefectDes,
                    DefectNum);
        }
    }

    @Override
    public void getDefaultGroup(String LoginName) {
        if (null != model) {
            model.getDefaultGroup(this, LoginName);
        }
    }

    @Override
    public void onSuccess(GroupBean groupBean) {
        if (null != view) {
            view.onSuccess(groupBean);
        }
    }

    @Override
    public void onSuccess(FlowLineBean flowLineBean) {
        if (null != view) {
            view.onSuccess(flowLineBean);
        }
    }

    @Override
    public void onSuccess(ProducerBean producerBean) {
        if (null != view) {
            view.onSuccess(producerBean);
        }
    }

    @Override
    public void onSuccess(DefaultGroupBean defaultGroupBean) {
        if (null != view) {
            view.onSuccess(defaultGroupBean);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onSuccess(baseBean);
        }
    }

    /**
     * 以下内容复用
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}
